package io.confluent.kafka.consumer.conf;

import java.io.*;
import java.util.Properties;

/**
 * Created by taotao on 2017/12/14.
 */
public final class PropertiesReader {
    public static String KAFKA_BOOTSTRAP_SERVERS;
    public static String KAFKA_CONSUMER_TOPICS_EVENT;
    public static String KAFKA_CONSUMER_GROUP_EVENT;
    public static int KAFKA_CONSUMER_POLL_TIMEOUT;
    public static String KAFKA_CONSUMER_TOPICS_PERFORMACE;
    public static String KAFKA_CONSUMER_GROUP_PERFORMACE;
    public static String OPENO_SERVER;
    public static String OPENO_PORT;
    public static String DEBUG;

    static {
        try {
            Properties props = new Properties();
            //File file = new File("D:\\Users\\Administrator\\IdeaProjects\\kafka_git\\kafka_rest\\src\\main\\resources\\config.properties");
            File file = new File("/root/config.properties");
            FileInputStream fis = new FileInputStream(file);
            props.load(fis);
            fis.close();
            //InputStream in = PropertiesReader.class.getClassLoader().getResourceAsStream("config.properties");
            //props.load(new BufferedReader(new InputStreamReader(in,"utf-8")));
            KAFKA_BOOTSTRAP_SERVERS = (String) props.get("kafka.bootstrap.servers");
            KAFKA_CONSUMER_TOPICS_EVENT = (String) props.get("kafka.consumer.topics.event");
            KAFKA_CONSUMER_GROUP_EVENT = (String) props.get("kafka.consumer.group.event");
            KAFKA_CONSUMER_POLL_TIMEOUT = Integer.parseInt((String) props.get("kafka.consumer.pollTimeout"));
            KAFKA_CONSUMER_TOPICS_PERFORMACE = (String) props.get("kafka.consumer.topics.performance");
            KAFKA_CONSUMER_GROUP_PERFORMACE = (String) props.get("kafka.consumer.group.performance");
            OPENO_SERVER = (String) props.get("openo.server");
            OPENO_PORT = (String) props.get("openo.port");
            DEBUG = (String) props.get("debug");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
